<!-- BEGIN FORM-SEARCH -->
<?php echo $this->element('form-search'); ?>
<!-- END FORM-SEARCH -->

<div class="nav-container">
	<a href="/search">Máy Tốt</a>
	»
	<?php
		foreach ($regionAll as $item){
			if($searchRegion == ZERO){
				$regionDir = '';
				$regionName = 'Toàn quốc';
				break;
			}
			if($searchRegion == $item['Region']['region_id']){
				$regionDir = $item['Region']['region_id'];
				$regionName = $item['Region']['region_name'];
				break;
			}
		}
	?>
	<a href="/search?searchRegion=<?php echo $regionDir; ?>"><?php echo $regionName; ?></a>
	»
	<?php
		$categoryDir = '';
		$categoryName = 'Tất cả danh mục';
		foreach ($categoryAll as $item){
			// Empty get all
			if($searchCategory == POST_CATEGORY_ALL){
				$categoryDir = '';
				$categoryName = 'Tất cả danh mục';
				break;
			}
			// Not contain category child
			if($searchCategory == $item['RootCategory']['id'].'_'){
				$categoryDir = $item['RootCategory']['id'].'_';
				$categoryName = $item['RootCategory']['category_name'];
				break;
			}
			// Contain category child
			foreach ($item['Category'] as $cat){
				if($searchCategory == $item['RootCategory']['id'].'_'.$cat['category_id']){
					$categoryDir = $item['RootCategory']['id'].'_'.$cat['category_id'];
					$categoryName = $cat['category_name'];
					break;
				}
			}
		}
	?>
	<a href="/search?searchRegion=<?php echo $regionDir; ?>&searchCategory=<?php echo $categoryDir; ?>"><?php echo $categoryName;?></a>
</div>

<div class="tabs-container">
	<ul class="nav nav-tabs" role="tablist" id="myTab">
	  	<li <?php 
				if($searchPersonCompany == ZERO)
				{
			?>
			    class="active"
			<?php
				}
			?>
		>
		<a href="/search?searchPersonCompany=<?php echo ZERO; ?>&searchText=<?php echo $searchText; ?>&searchRegion=<?php echo $regionDir; ?>&searchCategory=<?php echo $categoryDir; ?>&searchBuySell=<?php echo $searchBuySell; ?>">Tất cả</a></li>

	  	<li <?php 
				if($searchPersonCompany == POST_PERSON)
				{
			?>
				class="active"
			<?php
				}
			?>
		>
		<a href="/search?searchPersonCompany=<?php echo POST_PERSON; ?>&searchText=<?php echo $searchText; ?>&searchRegion=<?php echo $regionDir; ?>&searchCategory=<?php echo $categoryDir; ?>&searchBuySell=<?php echo $searchBuySell; ?>">Cá nhân</a></li>

	  	<li <?php 
				if($searchPersonCompany == POST_COMPANY)
				{
			?>
				class="active"
			<?php
				}
			?>
		>
		<a href="/search?searchPersonCompany=<?php echo POST_COMPANY; ?>&searchText=<?php echo $searchText; ?>&searchRegion=<?php echo $regionDir; ?>&searchCategory=<?php echo $categoryDir; ?>&searchBuySell=<?php echo $searchBuySell; ?>">Công ty</a></li>
	</ul>

	<div class="tab-content">
	  	<div role="tabpanel" class="tab-pane active" id="tab-all">
	  		<?php echo $this->element('content-tab-all'); ?>
	  	</div>
	</div>
</div>

</div>
<div class="pagination pagination-centered">
	<?php
		if ($this -> Paginator -> counter('{:pages}') > 1) {
	 		echo $this -> element('pagination', array('Paginator' => $this -> Paginator));
	 	}
 	?>
</div>